export interface User {
  id: string
  name: string
  email: string
  avatar?: string
  createdAt: Date
  updatedAt: Date
}

export interface Sheet {
  id: string
  title: string
  description?: string
  createdAt: Date
  updatedAt: Date
  ownerId: string
  owner: User
  members: SheetMember[]
  cells: Cell[]
  shareToken?: string
  isPublic: boolean
  allowEdit: boolean
}

export interface SheetMember {
  id: string
  role: MemberRole
  joinedAt: Date
  userId: string
  user: User
  sheetId: string
}

export interface Cell {
  id: string
  row: number
  column: number
  value?: string
  formula?: string
  style?: CellStyle
  createdAt: Date
  updatedAt: Date
  sheetId: string
}

export interface CellStyle {
  backgroundColor?: string
  color?: string
  fontWeight?: 'normal' | 'bold'
  fontStyle?: 'normal' | 'italic'
  textAlign?: 'left' | 'center' | 'right'
  border?: {
    top?: boolean
    right?: boolean
    bottom?: boolean
    left?: boolean
  }
}

export enum MemberRole {
  OWNER = 'OWNER',
  EDITOR = 'EDITOR',
  VIEWER = 'VIEWER'
}

export interface CollaborativeUser {
  id: string
  name: string
  avatar?: string
  color: string
  cursor?: {
    row: number
    column: number
  }
  selection?: {
    startRow: number
    startColumn: number
    endRow: number
    endColumn: number
  }
}

export interface SheetUpdate {
  type: 'cell_update' | 'cell_insert' | 'cell_delete' | 'style_update'
  cellId?: string
  row?: number
  column?: number
  value?: string
  formula?: string
  style?: CellStyle
  userId: string
  timestamp: number
}
